﻿using System.Collections.Generic;
using Glue;
using Xunit;

namespace GlueTests.MapperTests
{
    public class When_mapping_between_Enumerables_with_unset_values
    {
                private readonly FromPerson fromPerson;
        private readonly Mapping<FromPerson, ToPerson> mapping;
        private ToPerson toPerson;

        public class FromPerson
        {
            public List<int> List { get; set; }
            public IList<int> IList { get; set; }
            public ICollection<int> ICollection { get; set; }
            public IEnumerable<int> IEnumerable { get; set; }
        }

        public class ToPerson
        {
            public List<int> List { get; set; }
            public IList<int> IList { get; set; }
            public ICollection<int> ICollection { get; set; }
            public IEnumerable<int> IEnumerable { get; set; }
        }

        public When_mapping_between_Enumerables_with_unset_values()
        {
            mapping = new Mapping<FromPerson, ToPerson>();
            mapping.AutoRelateEqualNames();

            fromPerson = new FromPerson
                 {
                     List = null,
                     IList = null,
                     ICollection = null,
                     IEnumerable = null
                 };

            toPerson = mapping.Map(fromPerson, new ToPerson());
        }

        [Fact]
        public void Should_map_between_Lists()
        {
            Assert.Null(toPerson.List);
        }

        [Fact]
        public void Should_map_between_ICollections()
        {
            Assert.Null(toPerson.ICollection);
        }
        [Fact]
        public void Should_map_between_IEnumerables()
        {
            Assert.Null(toPerson.IEnumerable);
        }

        [Fact]
        public void Should_map_between_ILists()
        {
            Assert.Null(toPerson.IList);
        }
    }
}
